<template>
  <el-table :data="tableData" class="data_table">
    <el-table-column prop="company" label="客户名称" width="180">
    </el-table-column>
    <el-table-column prop="applicanter" label="申请人" width="180">
    </el-table-column>
    <el-table-column prop="type" label="申请类型">
    </el-table-column>
    <el-table-column prop="issuedTime" label="开始时间">
    </el-table-column>
    <el-table-column prop="expiryTime" label="结束时间">
    </el-table-column>
    <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
      <template slot-scope="scope">
        <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="download(scope.row)"
        >下载</el-button>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
import axios from "axios";
import fileDownload from 'js-file-download'

export default {
  name: "ListApply",
  data () {
    return {
      formData: {
        applicanter: undefined,
        company: undefined,
        field108: null,
        reason: undefined,
        version: undefined,
        macAddress: undefined,
        department: undefined,
        type: undefined,
        expiryTime: null,
        description: undefined,
        state: false,
      },
      tableData: [{
        company: '2016001',
        applicanter: '小明',
        type: '这是第一条数据'
      }, {
        company: '2016002',
        applicanter: '小明',
        type: '这是第二条数据'
      }, {
        company: '2016003',
        applicanter: '小明',
        type: '这是第三条数据'
      }, {
        company: '2016004',
        applicanter: '小明',
        type: '这是第四条数据'
      }, {
        company: '2016005',
        applicanter: '小明',
        type: '这是第五条数据'
      }]
    }
  },

  created() {
    this.getList();
  },
  methods: {
    goTarget(href) {
      window.open(href, "_blank");
    },
    getList() {
      this.loading = true;
      axios
          .post('api/license/listPassApplicantion',this.formData).then(response => {

        this.tableData = response.data.rows;
        // this.total = response.total;
        this.loading = false;
      });
    },
    download(row){
      // alert("download"+row.id);
      axios.post('api/license/downLoadLicense/'+row.id, row.id, {responseType: 'arraybuffer'}).then(res => {
        fileDownload(res.data, 'license.lic')
      })

    },
    // fail(row){
    //   // alert("fail"+row.id);
    // },
  }
}
</script>

<style scoped>

</style>
